<template>
  <el-container class="container">
    <!-- 左侧导航 -->
    <el-aside width="200px"
              class="aside-container">
      <div class="aside-top">
        <h1 class="title-text">充电桩运营管理</h1>
      </div>
      <el-menu default-active="1"
               class="nav-menu"
               @open="handleOpen"
               @close="handleClose"
               background-color="transparent"
               text-color="#333"
               active-text-color="#1890ff"
               router>

        <!-- 首页 -->
        <el-menu-item index="/">
          <i class="el-icon-house"></i>
          <span slot="title">首页</span>
        </el-menu-item>

        <!-- 实时监控 -->
        <el-submenu index="2">
          <template slot="title">
            <i class="el-icon-camera-solid"></i>
            <span>实时监控</span>
          </template>
          <el-menu-item index="2-1">
            <span>实时监控</span>
          </el-menu-item>
          <el-menu-item index="2-2">
            <span>设备状态</span>
          </el-menu-item>
        </el-submenu>

        <!-- 站桩管理 -->
        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-s-unfold"></i>
            <span>站桩管理</span>
          </template>
          <el-menu-item index="/stationDisplay">
            <span>充电站管理</span>
          </el-menu-item>
          <el-menu-item index="/pileDisplay">
            <span>充电桩管理</span>
          </el-menu-item>
        </el-submenu>

        <!-- 运营管理 -->
        <el-submenu index="4">
          <template slot="title">
            <i class="el-icon-s-marketing"></i>
            <span>运营管理</span>
          </template>
          <el-menu-item index="/cardDisplay">
            <span>充电卡管理</span>
          </el-menu-item>
          <el-menu-item index="/shareDisplay">
            <span>共享管理</span>
          </el-menu-item>
          <el-menu-item index="/bookingDisplay">
            <span>预约管理</span>
          </el-menu-item>
          <el-menu-item index="/costRuleDisplay">
            <span>计费规则</span>
          </el-menu-item>
          <el-menu-item index="/clientDisplay">
            <span>客户管理</span>
          </el-menu-item>
          <el-menu-item index="/vehicleDisplay">
            <span>车辆管理</span>
          </el-menu-item>
        </el-submenu>

        <!-- 订单管理 -->
        <el-submenu index="5">
          <template slot="title">
            <i class="el-icon-s-order"></i>
            <span>订单管理</span>
          </template>
          <el-menu-item index="5-1">
            <span>充电记录</span>
          </el-menu-item>
          <el-menu-item index="5-2">
            <span>交易流水</span>
          </el-menu-item>
          <el-menu-item index="5-3">
            <span>充值记录</span>
          </el-menu-item>
          <el-menu-item index="5-4">
            <span>结转记录</span>
          </el-menu-item>
        </el-submenu>

        <!-- 报警管理 -->
        <el-submenu index="6">
          <template slot="title">
            <i class="el-icon-warning"></i>
            <span>报警管理</span>
          </template>
          <el-menu-item index="/alarmSetDisplay">
            <span>报警设置</span>
          </el-menu-item>
          <el-menu-item index="/alarmMsgDisplay">
            <span>报警消息</span>
          </el-menu-item>
        </el-submenu>

        <!-- 运维管理 -->
        <el-submenu index="7">
          <template slot="title">
            <i class="el-icon-s-tools"></i>
            <span>运维管理</span>
          </template>
          <el-menu-item index="/taskDisplay">
            <span>任务管理</span>
          </el-menu-item>
          <el-menu-item index="/accendentDisplay">
            <span>运维人员</span>
          </el-menu-item>
        </el-submenu>

        <!-- 分析报表 -->
        <el-submenu index="8">
          <template slot="title">
            <i class="el-icon-s-data"></i>
            <span>分析报表</span>
          </template>
          <el-menu-item index="8-1">
            <span>运营分析</span>
          </el-menu-item>
          <el-menu-item index="8-2">
            <span>客户分析</span>
          </el-menu-item>
          <el-menu-item index="8-3">
            <span>故障分析</span>
          </el-menu-item>
          <el-menu-item index="8-4">
            <span>能耗报表</span>
          </el-menu-item>
          <el-menu-item index="8-5">
            <span>财务报表</span>
          </el-menu-item>
        </el-submenu>

        <!-- 系统管理 -->
        <el-submenu index="9">
          <template slot="title">
            <i class="el-icon-s-operation"></i>
            <span>系统管理</span>
          </template>
          <el-menu-item index="/deptDisplay">
            <span>部门管理</span>
          </el-menu-item>
          <el-menu-item index="/">
            <span>用户管理</span>
          </el-menu-item>
          <el-menu-item index="9-3">
            <span>角色管理</span>
          </el-menu-item>
          <el-menu-item index="9-4">
            <span>系统日志</span>
          </el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>

    <!-- 右侧主区域 -->
    <el-container>
      <el-header class="header-style">
        <div class="header-content">
          <div class="header-right">
            <div class="header-icon">
              <i class="el-icon-monitor"></i>
            </div>

            <div class="header-icon message-badge-container">
              <i class="el-icon-message"></i>
              <span class="message-badge">3</span>
            </div>

            <div class="header-icon">
              <i class="el-icon-switch-button"></i>
            </div>

            <el-avatar class="user-avatar"
                       :size="36"
                       src="../assets/logo.png" />
          </div>
        </div>
      </el-header>

      <el-main class="main-style">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
  export default {
    data () {
      return {
        testParam: { name: 'haha' }
      }
    },
    methods: {
      handleOpen (key, keyPath) {
        console.log('菜单展开:', key, keyPath);
      },
      handleClose (key, keyPath) {
        console.log('菜单关闭:', key, keyPath);
      }
    },
    created () {
    }
  }
</script>

<style scoped>
  /* 全局容器样式 */
  .container {
    height: 100vh;
    min-width: 1200px;
  }

  /* 左侧导航样式 */
  .aside-container {
    width: 200px !important;
    background-color: rgb(248, 249, 250);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
  }

  .aside-top {
    height: 60px;
    background-color: rgb(22, 141, 244); /* 与Header保持一致 */
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
  }

  .title-text {
    color: white;
    font-weight: 700;
    font-size: 20px;
    margin: 0;
    line-height: 1.3;
  }

  .nav-menu {
    height: calc(100vh - 64px);
    overflow-y: auto;
    border-right: none;
  }

  /* 右侧Header样式 */
  /* 确保Header没有额外的边框或内边距影响高度 */
  .header-style {
    height: 64px;
    background-color: rgb(22, 141, 244);
    padding: 0 32px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: none; /* 确保没有边框 */
    box-sizing: border-box; /* 确保padding不影响总高度 */
  }

  .header-content {
    display: flex;
    justify-content: flex-end; /* 替换float实现右对齐 */
    height: 100%;
  }

  .header-right {
    display: flex;
    align-items: center;
    gap: 24px;
  }

  .header-icon {
    position: relative;
    font-size: 22px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s;
    padding: 8px;
  }

  .header-icon:hover {
    color: white;
    transform: scale(1.1);
  }

  /* 消息红标修复 */
  .message-badge {
    position: absolute;
    top: 2px; /* 调整垂直位置 */
    right: -2px; /* 调整水平位置 */
    background: #ff4d4f;
    color: white;
    font-size: 12px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    text-align: center;
    padding: 0 4px;
    transform: translate(50%, -50%); /* 精确定位 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  /* 用户头像 */
  .user-avatar {
    border: 2px solid rgba(255, 255, 255, 0.8);
    transition: all 0.3s;
  }

  .user-avatar:hover {
    border-color: white;
    transform: scale(1.05);
  }

  /* 主内容区 */
  .main-style {
    background-color: rgb(242, 242, 242);
    padding: 20px;
  }

  /* 菜单交互样式 */
  .el-menu-item:hover {
    background-color: rgba(22, 141, 244, 0.1) !important;
  }

  .el-menu-item.is-active {
    background-color: rgba(22, 141, 244, 0.15) !important;
  }

  /* 响应式调整 */
  @media (max-width: 1400px) {
    .header-style {
      padding: 0 24px !important;
    }
    .header-right {
      gap: 20px;
    }
  }

  @media (max-width: 1280px) {
    .container {
      min-width: 100%;
    }
  }

  /* 修改后的层级缩进样式 - 使用Vue 2的深度选择器语法 */
  /deep/ .el-menu--inline {
    padding-left: 20px;
  }

  /deep/ .el-menu-item,
  /deep/ .el-submenu__title {
    padding-left: 20px !important;
  }

  /deep/ .el-submenu .el-menu-item {
    padding-left: 40px !important;
  }

  /deep/ .el-menu--inline {
    background-color: rgba(240, 242, 245, 0.8) !important;
  }

  /* 更安全的限定范围的选择器 */
  .nav-menu /deep/ .el-menu-item,
  .nav-menu /deep/ .el-submenu__title {
    padding-left: 20px !important;
  }

  .nav-menu /deep/ .el-submenu .el-menu-item {
    padding-left: 40px !important;
  }

  .nav-menu /deep/ .el-menu--inline {
    background-color: rgba(240, 242, 245, 0.8) !important;
  }

  /*/* 层级缩进样式 */
  /*:deep(.el-menu--inline) {*/
  /*  padding-left: 20px;*/
  /*}*/
  /**/
  /*:deep(.el-menu-item),*/
  /*:deep(.el-submenu__title) {*/
  /*  padding-left: 50px; /* 一级菜单项缩进 */
  /*}*/
  /**/
  /*:deep(.el-submenu .el-menu-item) {*/
  /*  padding-left: 70px; /* 二级菜单项缩进 */
  /*}*/
  /*/* 新增更精确的菜单缩进控制 */
  /*:deep(.el-menu-item),*/
  /*:deep(.el-submenu__title) {*/
  /*  padding-left: 20px !important;*/
  /*}*/
  /**/
  /*:deep(.el-submenu .el-menu-item) {*/
  /*  padding-left: 40px !important;*/
  /*}*/
  /**/
  /*:deep(.el-menu--inline) {*/
  /*  background-color: rgba(240, 242, 245, 0.8) !important;*/
  /*}*/
</style>